'use strict';

const {getDefaultModelConfig} = require("../../utils/common");
module.exports = app => {
  const { STRING, BIGINT, INTEGER, DATE, TINYINT } = app.Sequelize;

  return app.model.define('SystemRole', {
    id: {
      type: BIGINT,
      primaryKey: true,
      autoIncrement: true,
      comment: '角色ID'
    },
    name: {
      type: STRING(30),
      allowNull: true,
      comment: '角色名称'
    },
    code: {
      type: STRING(100),
      allowNull: true,
      comment: '角色权限字符串'
    },
    sort: {
      type: INTEGER,
      allowNull: true,
      comment: '显示顺序'
    },
    dataScope: {
      type: INTEGER,
      allowNull: true,
      defaultValue: 1,
      field: 'data_scope',
      comment: '数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）'
    },
    dataScopeDeptIds: {
      type: STRING(500),
      allowNull: true,
      defaultValue: '',
      field: 'data_scope_dept_ids',
      comment: '数据范围(指定部门数组)'
    },
    status: {
      type: INTEGER,
      allowNull: true,
      comment: '角色状态（0正常 1停用）'
    },
    type: {
      type: INTEGER,
      allowNull: true,
      comment: '角色类型'
    },
    remark: {
      type: STRING(500),
      allowNull: true,
      comment: '备注'
    },
    ...getDefaultModelConfig(app)
  }, {
    tableName: 'system_role',
    timestamps: false, // 不使用Sequelize的默认时间戳字段
  });
};
